package com.hspedu.seckill.controller;

import com.hspedu.seckill.entity.User;
import com.hspedu.seckill.model.result.RespBean;
import com.hspedu.seckill.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author: xujiabing
 * @date: 2024-11-11 21:14
 * @description: 用户相关
 */
@Controller
@RequestMapping("/user")
public class UserController {
    @Resource
    private UserService userService;

    @RequestMapping("/info")
    @ResponseBody
    public RespBean info(User user, String address) {
        System.out.println("address: " + address);
        return RespBean.success(user);
    }

    /**
     * 更新用户密码
     * @param userTicket
     * @param password
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("/updpwd")
    @ResponseBody
    public RespBean updatePassword(String userTicket,
                                   String password,
                                   HttpServletRequest request,
                                   HttpServletResponse response) {

        return userService.updatePassword(userTicket,password,request,response);
    }
}
